package vip.meeet.async;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class AsyncStart {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringAsyncConfig.class);
        AsyncComponent bean = context.getBean(AsyncComponent.class);
        System.out.println(bean.doSomething("curitis"));
        bean.printName("curitis");
        System.out.println("main done");
        Future<String> curitis = bean.getAsyncResult("curitis");
        System.out.println(curitis.get());
    }
}
